package com.zhiyou100.action02;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author yang
 * @className Demo02
 * @packageName com.zhiyou100.action01
 * @Description TODO 测试
 * @date 2020-08-21 09:51
 */
public class Demo02 implements Controller {
    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        final ModelAndView view = new ModelAndView();

        final int code = Integer.parseInt(request.getParameter("code"));
        if (code == 1) {
            System.out.println("d21 请求转发到 success.jsp");
            view.addObject("message", "d2 请求转发到 success.jsp");
            view.setViewName("/test01/success.jsp");

        }
        int two = 2;
        if (code == two) {
            System.out.println("d21 请求转发到 action:::: /test02/d22.action");
            view.addObject("message", "d2 请求转发到 action:::: /test02/d22.action");
            view.setViewName("/action02/d3.action");
            // forward:/action02/d3.action 不用加前缀和后缀

        }

        return view;
    }
}
